<template>
  <div class="app-container">
    <el-tabs v-model="tabsRemark.activeName" @tab-click="tabsClick">
      <el-tab-pane
        :label="tabsRemark.history"
        name="tabsRemark.nameC"
      ></el-tab-pane>
    </el-tabs>
    <query></query>
    <el-table
      :data="transferManagementData"
      border
      fit
      highlight-current-row
      style="width: 100%"
      sort-change="dateSort"
    >
      <el-table-column
        align="center"
        sortable="custom"
        prop="transferVo.createdTime"
        :label="transferManagementRemark.createdTime"
        width="200"
      >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.transferVo.createdTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="userVo.username"
        :label="transferManagementRemark.username"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="userVo.phoneNumber"
        :label="transferManagementRemark.phoneNumber"
        width="160"
      >
      </el-table-column>
      <el-table-column
        prop="transferVo.money"
        :label="transferManagementRemark.money"
        width="110"
      >
      </el-table-column>
      <el-table-column
        prop="transferVo.remarks"
        :label="transferManagementRemark.remarks"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="transferVo.serviceCharge"
        :label="transferManagementRemark.serviceCharge"
        width="70"
      >
      </el-table-column>
      <el-table-column :label="transferManagementRemark.type" min-width="90px">
        <template #default="{ row }">
          <el-tag>{{ row.transferVo.type }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column :label="transferManagementRemark.status" min-width="90px">
        <template #default="{ row }">
          <el-tag>{{ row.transferVo.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        :label="transferManagementRemark.operation"
        align="center"
        min-width="110"
        class-name="fixed-width"
      >
        <template #default="{ row }">
          <el-button type="primary" size="mini" @click="handleSeekInfo(row)">
            {{ transferManagementRemark.seek }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="pageData.total"
      v-show="pageData.total > 0"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageData.currentPage"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper"
    />
    <info-dialogue
      :isVisible="transferManagementRemark.InfoDialogueIsVisible"
      :InformationValue="transferManagementDataOne"
      @hide="InfoDialogueHide"
      @updateData="getData"
    ></info-dialogue>
  </div>
</template>

<script>
import InfoDialogue from "./InfoDialogue.vue";
import query from "./query/index.vue";

export default {
  components: {
    query,
    InfoDialogue,
  },

  data() {
    return {
      tabsRemark: {
        onGoing: "进行中",
        history: "历史记录",
        activeName: "onGoing",
        nameA: "onGoing",
        nameB: "history",
      },
      transferManagementRemark: {
        id: "ID",
        status: "状态",
        type: "转账类型",
        money: "金额",
        serviceCharge: "手续费",
        remarks: "备注",
        createdTime: "转账时间",
        username: "用户名",
        phoneNumber: "手机号",
        operation: "操作",
        seek: "查看信息",
        edit: "编辑",
        success: "审批通过",
        danger: "不通过",
        InfoDialogueIsVisible: false,
      },
      transferManagementData: [],
      transferManagementDataOne: {},
      pageData: {
        total: 10,
        page: 1,
        limit: 10,
        currentPage: 1,
      },
    };
  },
  created() {
    this.getData();
  },
  // mounted(){
  //   this.getData();
  // },
  methods: {
    tabsClick() {},
    getData() {
      this.$store
        .dispatch("request/get", "/basic/transfer/history")
        .then((data) => {
          this.transferManagementData = data;
        });
    },
    handleSeekInfo(row) {
      this.transferManagementDataOne = row;
      this.transferManagementRemark.InfoDialogueIsVisible = true;
    },
    correct(transferId, flag) {
      let data = {
        transferId: transferId,
        ifPass: flag,
        url: "/basic/transfer/update/status",
      };
      this.$store.dispatch("request/getP", data).then(() => {
        if (flag) {
          this.$message.success("审批通过");
        } else {
          this.$message.error("审批不通过");
        }
        this.getData();
      });
    },
    InfoDialogueHide() {
      this.transferManagementRemark.InfoDialogueIsVisible = false;
    },
    handleCurrentChange() {},
    handleSizeChange() {},
  },
};
</script>
